//
//  LHPictureCell.m
//  Project_B
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 ZY. All rights reserved.
//

#import "LHPictureCell.h"

@implementation LHPictureCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    
    //图片
    self.image = [UIImageView new];
//    self.image.layer.masksToBounds = YES;
//    self.image.layer.cornerRadius = 5;
//    self.image.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.image];
    [self.image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(@10);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-20, 200));
        
    }];

    //标题
    self.setNameLable = [UILabel new];
    self.setNameLable.font = [UIFont systemFontOfSize:14*ADAPT_FONT];
    self.setNameLable.lineBreakMode = NSLineBreakByWordWrapping;
    self.setNameLable.numberOfLines = 0;
    [self.contentView addSubview:self.setNameLable];
    [self.setNameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.image).offset(10);
        make.top.equalTo(self.image.mas_bottom).offset(6);
        make.size.mas_equalTo(CGSizeMake(260, 25));
    }];
    
    //图片数
    _picNumImage = [UIImageView new];
    _picNumImage.image = [UIImage imageNamed:@"iconfont-tupian.png"];
    [self.contentView addSubview:_picNumImage];
    [_picNumImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_setNameLable.mas_bottom);
        make.left.equalTo(_setNameLable);
        make.size.mas_equalTo(CGSizeMake(15, 15));
        
    }];
    
    _picNum = [UILabel new];
    _picNum.font = [UIFont systemFontOfSize:12*ADAPT_FONT];
    _picNum.textColor = [UIColor grayColor];
    [self.contentView addSubview:_picNum];
    [_picNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_picNumImage);
        make.left.equalTo(_picNumImage.mas_right).offset(8);
        make.size.mas_equalTo(CGSizeMake(200, 15));
        
    }];
    
    
    //跟帖数
    _dicNum = [UILabel new];
    _dicNum.font = [UIFont systemFontOfSize:12*ADAPT_FONT];
    _dicNum.textColor = [UIColor grayColor];
    _dicNum.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_dicNum];
    [_dicNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_picNum);
        make.right.offset(-20);
        make.size.mas_equalTo(CGSizeMake(100, 15));
        
    }];
    
    //各种线
    UIView *aview = [UIView new];
    aview.backgroundColor = [UIColor colorWithWhite:0.700 alpha:1.000];
    [self.contentView addSubview:aview];
    [aview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_image);
        make.bottom.offset(0);
        make.size.mas_equalTo(CGSizeMake(1, 250-200+4));
        
    }];
    
    UIView *bview = [UIView new];
    bview.backgroundColor = [UIColor colorWithWhite:0.700 alpha:1.000];
    [self.contentView addSubview:bview];
    [bview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_image);
        make.bottom.offset(-1);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-20, 1));
        
    }];
    
    UIView *cview = [UIView new];
    cview.backgroundColor = [UIColor colorWithWhite:0.700 alpha:1.000];
    [self.contentView addSubview:cview];
    [cview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(@0);
        make.right.offset(-10);
        make.size.mas_equalTo(CGSizeMake(1, 250-200+4));
        
    }];


}

- (void)setModel:(PictureModel *)model {

    
    //    图片
    NSURL *url = [NSURL URLWithString:model.clientcover1];
    [self.image sd_setImageWithURL:url placeholderImage:PLACEHOLDER_IMAGE];
    
    //    名字赋值
    self.setNameLable.text = model.setname;
    
    //图片数
    _picNum.text = [NSString stringWithFormat:@"%ld",model.imgsum];
    
    //跟帖数
    _dicNum.text = [NSString stringWithFormat:@"%ld跟帖", model.replynum];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
